#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2021/4/24 17:03
# @Author  : LiShan
# @Email   : lishan_1997@126.com
# @File    : simulation_demo.py
# @Note    : this is note
import os
import agent.dqn as ag
from environment.vissim import VisEnv

net_path = os.getcwd().replace("\\", "/") + "/resource/vissim/3.inp"
simulation = [999999, 0, 1, 1, 42, False, False]
timming = [24, 38, 2, 130, 20, 3, [2, 2, 2, 2]]
env = VisEnv(net_path, simulation, timming)

ag.N_STATES = env.observation_space.shape[0]
ag.N_ACTIONS = env.action_space.n

if __name__ == '__main__':
    for i_episode in range(2):
        env.render()
        observation = env.reset()
        state = observation
        for t in range(5):
            # action = env.action_space.sample()
            action = ag.Agent().action(state)
            observation, reward, done, info = env.step(action)
            print(observation)
            print(reward)
            if done:
                print("Episode finished after {} timesteps".format(t + 1))
                break
        print("Episode {} finished".format(i_episode + 1))
    env.close()
